﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace UDPKeyboard
{
    public partial class Log : UserControl
    {
        List<string> logLines = new List<string>();

        public Log()
        {
            InitializeComponent();
        }

        public void LogEntry(string value)
        {
            logLines.Add(value);
            int lineCount = textBoxLog.Height / 14;
            int skipAmount = logLines.Count - lineCount;
            textBoxLog.Text = String.Join(Environment.NewLine, (skipAmount > 0 ? logLines.Skip(skipAmount) : logLines).ToArray());
            textBoxLog.SelectionStart = textBoxLog.Text.Length;
            textBoxLog.ScrollToCaret();
        }
    }
}
